package com.haixinga.commbiz.member.utils;

import com.haixinga.commbiz.commons.utils.SpringBeansUtil;
import com.haixinga.commbiz.commons.vo.*;
import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * 参数获取工具
 **/

@Component
@Getter
public class MemberPropKit {

    @Value("${isys.oss.key-id}")
    private String ossKeyId;

    @Value("${isys.oss.key-secret}")
    private String ossKeySecret;

    @Value("${isys.oss.bucket-name}")
    private String ossBucketName;

    @Value("${isys.oss.endpoint}")
    private String ossEndpoint;

    @Value("${isys.oss.expire-time}")
    private Long ossExpireTime;

    @Value("${isys.oss.max-size}")
    private Long ossMaxSize;

    @Value("${isys.wxminiapp.appid}")
    private String wxMiniAppid;

    @Value("${isys.wxminiapp.secret}")
    private String wxMiniSecret;

    @Value("${isys.wxpay.appId}")
    private String wxpayAppId;

    @Value("${isys.wxpay.mchId}")
    private String wxpayMchId;

    @Value("${isys.wxpay.mchKey}")
    private String wxpayMchKey;

    @Value("${isys.wxpay.notifyUrl}")
    private String wxpayNotifyUrl;

    @Value("${isys.wxmp.appId}")
    private String wxmpAppId;

    @Value("${isys.wxmp.appSecret}")
    private String wxmpAppSecret;

    @Value("${isys.wxmp.token}")
    private String wxmpToken;

    @Value("${isys.wxmp.encodingAESKey}")
    private String wxmpEncodingAESKey;

    @Value("${isys.sms.key-id}")
    private String smsAccessKeyId;

    @Value("${isys.sms.key-secret}")
    private String smsAccessSecret;

    @Value("${isys.sms.sign-name}")
    private String smsSignName;

    @Value("${isys.sms.sandbox}")
    private Boolean smsSandbox;

    /** 存放静态对象 **/
    private static MemberPropKit staticBean = null;
    private static synchronized MemberPropKit getStaticBean(){
        if(staticBean == null){
            staticBean = SpringBeansUtil.getBean(MemberPropKit.class);
        }
        return staticBean;
    }

    /** 对外提供static的get函数 */

    public static WxMiniVO getWxMiniConfig() {

        return new WxMiniVO(
                getStaticBean().wxMiniAppid,
                getStaticBean().wxMiniSecret
        );
    }

    public static WxPayVO getWxPayConfig() {

        return new WxPayVO(
                getStaticBean().wxpayAppId,
                getStaticBean().wxpayMchId,
                getStaticBean().wxpayMchKey,
                getStaticBean().wxpayNotifyUrl
        );
    }

    public static WxMpVO getWxMpConfig() {

        return new WxMpVO(
                getStaticBean().wxmpAppId,
                getStaticBean().wxmpAppSecret,
                getStaticBean().wxmpToken,
                getStaticBean().wxmpEncodingAESKey
        );
    }


    public static OssConfigVO getOssConfig() {

        return new OssConfigVO(
                getStaticBean().ossKeyId,
                getStaticBean().ossKeySecret,
                getStaticBean().ossBucketName,
                getStaticBean().ossEndpoint,
                getStaticBean().ossExpireTime,
                getStaticBean().ossMaxSize
        );
    }

    public static SMSConfigVO getSMSConfig() {
        return new SMSConfigVO(
                getStaticBean().smsAccessKeyId,
                getStaticBean().smsAccessSecret,
                getStaticBean().smsSignName,
                getStaticBean().smsSandbox
        );
    }



}
